<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<title>请医院内部工作人员进行注册</title>
<script type="text/javascript" src="js/trim.js"></script>
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	function validate(userfield) {
		if (trim(userfield.value).length != 0) {
			var xmlHttpRequest = null;
			var url = "AccountIsExistServlet?account=" + userfield.value;
			var usermsg = document.getElementById("usermsg");
			if (window.XMLHttpRequest) {//表示当前浏览器不是IE
				xmlHttpRequest = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlHttpRequest.open("GET", url, true);//设置请求方式为GET，设置请求的URL，设置为异步提交
			xmlHttpRequest.onreadystatechange = function(){//将方法地址复制给onreadystatechange属性
				if(xmlHttpRequest.readyState == 4){//Ajax引擎状态为成功
					if(xmlHttpRequest.status == 200){//HTTP协议状态为成功
						if(trim(xmlHttpRequest.responseText) != ""){
							usermsg.innerHTML = "<font color='red'>" + trim(xmlHttpRequest.responseText) + "</font>";
							userfield.focus();
						}else{
							usermsg.innerHTML = "恭喜您，用户名可以使用。 ";
						}
					}else{
						alert("请求失败，错误码=" + xmlHttp.status);
					}
				}
			};
			xmlHttpRequest.send(null);//将设置信息发送到Ajax引擎
		}else{
			usermsg.innerHTML = "";
		}
	}
	function sub(){
		var username = document.getElementById("username");
		var password = document.getElementById("password");
		var birthday = document.getElementById("birthday");
		var address = document.getElementById("address");
		var tel = document.getElementById("tel");
		if(trim(username.value).length == 0){
			alert("用户名不能为空。");
			username.focus();
		}else if(usermsg.innerHTML.length != 13){
			alert("用户已经存在。");
			username.focus();
		}else if(trim(password.value).length == 0){
			alert("密码不能为空。");
			password.focus();
		}else if(trim(address.value).length == 0){
			alert("用户地址不能为空。");
			address.focus();
		}else if(trim(tel.value).length == 0){
			alert("用户电话不能为空。");
			tel.focus();
		}else{
			document.forms["form"].submit();
		}
	}
</script>
</head>
<body>
	<div style="text-align: center;">
		<div style="margin:100px auto 10px auto; font-size: 26px; background:url(images/top.jpg); width:975px;height:190px;">
			<div style="height:10px;">&nbsp;</div>
			<div style="margin-top:100px; margin-left:220px;color:white;">
				<font color="white" face="微软雅黑">医院内部工作人员（临时员工）用户注册</font>
			</div>
		</div>
		<div style="margin-top: 50px;text-align: center;border:1px;">
			<div style="text-align: center;">
			<form action="RegServlet" method="post" name="form" id="form">
				<table style="margin-top: 30px;" border="0" align="center">
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td><font color="#FF0000">*</font>用户名：</td>
						<td><input type="text" name="account" id="username" maxlength="12" onblur="validate(this)"/></td>
						<td width="220px;"><span id="usermsg"></span></td>
					</tr>
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td><font color="#FF0000">*</font>密&nbsp;&nbsp;码：</td>
						<td><input type="password" name="pswd" id="password" maxlength="12" /></td>
						<td>&nbsp;</td>
					</tr>
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td><font color="#FF0000">*</font>性&nbsp;&nbsp;别：</td>
						<td>
							<input type="radio" name="sex" value="男" checked="checked"/> 男&nbsp;&nbsp;
							<input type="radio" name="sex" value="女" /> 女&nbsp;&nbsp;
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td><font color="#FF0000">*</font>出生日期：</td>
						<td><input id="d11" name="birthday" type="text" onClick="WdatePicker()"/></td>
						<td>&nbsp;</td>
					</tr>
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td><font color="#FF0000">*</font>地&nbsp;&nbsp;址：</td>
						<td><input type="text" name="address" id="address" maxlength="20" /></td>
						<td>&nbsp;</td>
					</tr>
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td><font color="#FF0000">*</font>电&nbsp;&nbsp;话：</td>
						<td><input type="text" name="tel" id="tel" maxlength="12" /></td>
						<td>&nbsp;</td>
					</tr>
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td colspan="2" align="center">
							&nbsp;${rs }
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr height="30px;">
						<td width="400px;">&nbsp;</td>
						<td colspan="2" align="center">
							<input type="button" value="注册" onclick="sub();"/>&nbsp;&nbsp;
							<input type="button" value="登录" onclick="window.location.href='index.jsp'" />
						</td>
						<td>&nbsp;</td>
					</tr>
				</table>
			</form>
			</div>
		</div>
	</div>
</body>
</html>